from pydantic import BaseModel, Field
from typing import Optional

from decimal import Decimal
from datetime import datetime
from datetime import date


class ProjectQuery(BaseModel):
    page: int = Field(1, ge=1, description="页码", alias="current")
    size: int = Field(10, ge=1, le=100, description="每页数量")

    id: Optional[int] = Field(None, description="按 项目主键 过滤")
    code: Optional[str] = Field(None, description="按 项目代号 字符串模糊匹配")
    name: Optional[str] = Field(None, description="按 项目名称 字符串模糊匹配")
    case_id: Optional[int] = Field(None, description="按 关联案情ID 过滤")
    presale_entry_time: Optional[datetime] = Field(None, description="按 售前进入时间 过滤")
    presale_pm: Optional[str] = Field(None, description="按 售前PM 字符串模糊匹配")
    presale_person: Optional[str] = Field(None, description="按 售前 字符串模糊匹配")
    customer_code: Optional[str] = Field(None, description="按 客户编号 字符串模糊匹配")
    customer_name: Optional[str] = Field(None, description="按 客户名称 字符串模糊匹配")
    salesperson: Optional[str] = Field(None, description="按 salesperson 字符串模糊匹配")
    department: Optional[str] = Field(None, description="按 事业部 字符串模糊匹配")
    opportunity_category: Optional[str] = Field(None, description="按 商机类别 字符串模糊匹配")
    products: Optional[str] = Field(None, description="按 产品线 字符串模糊匹配")
    agile_product_line: Optional[str] = Field(None, description="按 敏态产品 字符串模糊匹配")
    project_phase: Optional[str] = Field(None, description="按 项目阶段 字符串模糊匹配")
    project_progress: Optional[str] = Field(None, description="按 项目进度 字符串模糊匹配")
    factory_progress: Optional[str] = Field(None, description="按 工厂建设状况 字符串模糊匹配")
    factory_planning: Optional[str] = Field(None, description="按 工厂规划需求 字符串模糊匹配")
    competitors: Optional[str] = Field(None, description="按 竞争对手 字符串模糊匹配")
    customer_budget: Optional[Decimal] = Field(None, description="按 客户预算 过滤")
    last_update_time: Optional[datetime] = Field(None, description="按 最近更新时间 过滤")
    recent_notes: Optional[str] = Field(None, description="按 近况备注 字符串模糊匹配")
    expected_signing_date: Optional[date] = Field(None, description="按 预计签约日 过滤")
    confidence_level: Optional[str] = Field(None, description="按 把握度 字符串模糊匹配")
    high_level_description: Optional[str] = Field(None, description="按 高阶论述 字符串模糊匹配")
    quote_amount_total: Optional[Decimal] = Field(None, description="按 报价-总金额 过滤")
    signing_status_date: Optional[datetime] = Field(None, description="按 签约/战败/暂停日 过滤")
    contract_amount_total: Optional[Decimal] = Field(None, description="按 签约-总金额 过滤")
    create_time: Optional[datetime] = Field(None, description="按 创建时间 过滤")
    update_time: Optional[datetime] = Field(None, description="按 更新时间 过滤")
    case_report_score: Optional[int] = Field(None, description="按 案情报告总分 过滤")
    quality_level: Optional[str] = Field(None, description="按 质量等级 字符串模糊匹配")
    quality_score: Optional[int] = Field(None, description="按 质量分数 过滤")
    project_authenticity: Optional[str] = Field(None, description="按 项目真伪 字符串模糊匹配")
    authenticity_score: Optional[int] = Field(None, description="按 真伪分数 过滤")
    win_rate: Optional[str] = Field(None, description="按 项目胜率 字符串模糊匹配")
    win_rate_score: Optional[int] = Field(None, description="按 胜率分数 过滤")
    erp_status: Optional[str] = Field(None, description="按 信息化应用状况 字符串模糊匹配")
    mes_status: Optional[str] = Field(None, description="按 MES状况 字符串模糊匹配")
    project_scale: Optional[str] = Field(None, description="按 项目规模（纯数值，如人数、金额等） 字符串模糊匹配")
    created_by: Optional[str] = Field(None, description="按 创建人 字符串模糊匹配")
    updated_by: Optional[str] = Field(None, description="按 更新人 字符串模糊匹配")
    created_dept: Optional[str] = Field(None, description="按 创建人部门 字符串模糊匹配")
    research_date: Optional[date] = Field(None, description="按 调研日期 过滤")
    proposal_date: Optional[date] = Field(None, description="按 提案日期 过滤")
    project_approval_date: Optional[date] = Field(None, description="按 立项日期 过滤")
    salers_id: Optional[int] = Field(None, description="按 销售人员ID，关联salesperson表 过滤")
    is_sprint_project: Optional[str] = Field(None, description="按 冲刺项目否 Y/N 字符串模糊匹配")

    presale_entry_time_from: Optional[datetime] = Field(None, description="售前进入时间 起始")
    presale_entry_time_to: Optional[datetime] = Field(None, description="售前进入时间 结束")
    last_update_time_from: Optional[datetime] = Field(None, description="最近更新时间 起始")
    last_update_time_to: Optional[datetime] = Field(None, description="最近更新时间 结束")
    expected_signing_date_from: Optional[date] = Field(None, description="预计签约日 起始")
    expected_signing_date_to: Optional[date] = Field(None, description="预计签约日 结束")
    signing_status_date_from: Optional[datetime] = Field(None, description="签约/战败/暂停日 起始")
    signing_status_date_to: Optional[datetime] = Field(None, description="签约/战败/暂停日 结束")
    create_time_from: Optional[datetime] = Field(None, description="创建时间 起始")
    create_time_to: Optional[datetime] = Field(None, description="创建时间 结束")
    update_time_from: Optional[datetime] = Field(None, description="更新时间 起始")
    update_time_to: Optional[datetime] = Field(None, description="更新时间 结束")
    research_date_from: Optional[date] = Field(None, description="调研日期 起始")
    research_date_to: Optional[date] = Field(None, description="调研日期 结束")
    proposal_date_from: Optional[date] = Field(None, description="提案日期 起始")
    proposal_date_to: Optional[date] = Field(None, description="提案日期 结束")
    project_approval_date_from: Optional[date] = Field(None, description="立项日期 起始")
    project_approval_date_to: Optional[date] = Field(None, description="立项日期 结束")
